package com.first.system.service.Impl;

import cn.hutool.crypto.digest.DigestUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.first.common.pojo.AclUser;
import com.first.system.mapper.UserMapper;
import com.first.system.service.LoginService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @program: finrsteducation-parent
 * @description:
 * @author: 张玉森
 * @create: 2023-05-25 20:52
 **/
@Service
public class LoginServiceImpl implements LoginService {
    @Resource
    private UserMapper userMapper;
    @Override
    public AclUser findByNameAndPwd(String username, String password) {
        QueryWrapper<AclUser> wrapper = new QueryWrapper<>();
        wrapper.eq("username", username);
        //把输入的密码加盐
        wrapper.eq("password", DigestUtil.md5Hex(password));
        AclUser user = userMapper.selectOne(wrapper);
        return user;
    }
}
